package com.example.photoview;

import java.io.File;
import java.nio.file.Path;

public class ImageModel {
    private String imageFilePath;//图片的绝对路径
    private String FilePath;//图片文件所在地址
    private File imageFile;//图片文件
    private String imageNoExName;//图片不含扩展名的名字
    private String imageType;//图片类型（png,gif,jpg,bmp,jepg)
    private long fileLength;//文件长度（字节）
    private long imageDate;//文件修改日期
    private String imageName;//图片名字

    public ImageModel (File file){
this.imageFile=file;
this.FilePath=file.getParent();
this.imageFilePath=file.getAbsolutePath();
this.imageName=file.getName();
this.fileLength=file.length();
this.imageDate=file.lastModified();
this.imageType = imageName.substring(imageName.indexOf(".") + 1).toLowerCase();
this.imageNoExName=imageName.substring(0, imageName.lastIndexOf("."));
    }
    public ImageModel ( String path){
        this.imageFile=new File(path);
        this.FilePath=imageFile.getParent();
        this.imageFilePath=path;
        this.imageName=imageFile.getName();
        this.fileLength=imageFile.length();
        this.imageDate=imageFile.lastModified();
        this.imageType = imageName.substring(imageName.indexOf(".") + 1).toLowerCase();
        this.imageNoExName=imageName.substring(0, imageName.lastIndexOf("."));
    }

    public long getFileLength() {
        return fileLength;
    }

    //规范格式
public String getFormLength(){
        return Model.getFormLength(this.fileLength);
    }
    public String getFormDate(){
        return Model.getFormDate(this.imageDate);
    }

    public long getImageDate() {
        return imageDate;
    }
}
